//495. 提莫攻击

int findPoisonedDuration(int* timeSeries, int timeSeriesSize, int duration) {
    int time = 0;
    for (int i = 1; i < timeSeriesSize; i++)
    {
        if (timeSeries[i] - timeSeries[i - 1] < duration)
            time += timeSeries[i] - timeSeries[i - 1];
        else
            time += duration;
    }
    time += duration;//最后一次的攻击持续时间
    return time;
}